<?php

/**
 * Modifies the YouTube table so it can take a YouTube url instead of a video ID
 *
 */
class Db_010_bbce_modify_slidetype_storage extends Ot_Migrate_Migration_Abstract
{
    public function up($dba)
    {
        $query = "
            
            CREATE TABLE IF NOT EXISTS `" . $this->tablePrefix . "tbl_slidetype_data` (
              `slideId` int(10) unsigned NOT NULL,
              `data` text NOT NULL,
              PRIMARY KEY (`slideId`)
            ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
            
            RENAME TABLE `" . $this->tablePrefix . "tbl_plugin_slidetype`  TO `" . $this->tablePrefix . "tbl_slidetype`;
            
            DROP TABLE `" . $this->tablePrefix . "tbl_plugin_slidetype_flickr`, 
                `" . $this->tablePrefix . "tbl_plugin_slidetype_flv`, 
                `" . $this->tablePrefix . "tbl_plugin_slidetype_image`, 
                `" . $this->tablePrefix . "tbl_plugin_slidetype_url`, 
                `" . $this->tablePrefix . "tbl_plugin_slidetype_visibletweets`, 
                `" . $this->tablePrefix . "tbl_plugin_slidetype_youtube`;
                
            ALTER TABLE `" . $this->tablePrefix . "tbl_slidetype` CHANGE `moduleName` `slidetype` VARCHAR( 128 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL;
            
            ALTER TABLE `" . $this->tablePrefix . "tbl_slidetype` DROP `type`;
        ";
        
        $dba->query($query);
    }

    public function down($dba) {
        
    }    
}